package com.quicksure.mobile.controller;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.quicksure.mobile.constants.LudiConstants;
import com.quicksure.mobile.entity.InsuranceDetailsVO;
import com.quicksure.mobile.service.OrderHandleService;

//订单操作
@Controller
@RequestMapping("/orderHandle")
public class OrderHandleController {
	private static final Logger logger = Logger.getLogger(OrderHandleController.class);
	@Resource
	private OrderHandleService orderHandleService;
	/**
	 * 撤销订单
	 * @return
	 */
	@RequestMapping("/cancelOrder.do")
	@ResponseBody
	public String cancelOrder(String orderno, HttpServletRequest request){
 		String msg = orderHandleService.cancelOrder(orderno,request);
		return msg;
	}
	
	/**
	 * CSR订单详情
	 */
	@RequestMapping("/orderDetails.do")
	public String CSROrderDetails(String orderno, HttpServletRequest request,ModelMap model){
		InsuranceDetailsVO insuranceDetailsVO = orderHandleService.getOrderDetailInfor(orderno, request);
		model.addAttribute("insuranceDetailsVO", insuranceDetailsVO);
		return LudiConstants.CSRORDERDETAILS;
	}
	
	/**
	 * CSR继续投保
	 */
	@RequestMapping("/CSRContinueInsure.do")
	public String CSRContinueInsure(String orderno, HttpServletRequest request,ModelMap model){
		InsuranceDetailsVO insuranceDetailsVO = orderHandleService.getOrderDetailInfor(orderno, request);
		model.addAttribute("insuranceDetailsVO", insuranceDetailsVO);
		return LudiConstants.USERMATION;
	}
	
	/**
	 * CSR订单导出excel
	 */
	@RequestMapping("exportExcel.do")
	public void CSRExportExcel(HttpServletRequest request,HttpServletResponse response){
		orderHandleService.exportExcel(request,response);
	}
}
